<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
                                                                                                          <el-form-item label="用户id" prop="usrId">
                    <el-input
                        v-model="queryParams.usrId"
                        placeholder="请输入用户id"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="客户号" prop="custNo">
                    <el-input
                        v-model="queryParams.custNo"
                        placeholder="请输入客户号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="内部订单号" prop="paymentReference">
                    <el-input
                        v-model="queryParams.paymentReference"
                        placeholder="请输入内部订单号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="第三方订单号" prop="transactionReference">
                    <el-input
                        v-model="queryParams.transactionReference"
                        placeholder="请输入第三方订单号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="已付金额" prop="amountPaid">
                    <el-input
                        v-model="queryParams.amountPaid"
                        placeholder="请输入已付金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="需付总金额" prop="totalPayable">
                    <el-input
                        v-model="queryParams.totalPayable"
                        placeholder="请输入需付总金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="结算金额" prop="settlementAmount">
                    <el-input
                        v-model="queryParams.settlementAmount"
                        placeholder="请输入结算金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="支付时间" prop="paidOn">
                    <el-input
                        v-model="queryParams.paidOn"
                        placeholder="请输入支付时间"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="支付状态" prop="paymentStatus">
                    <el-select v-model="queryParams.paymentStatus" placeholder="请选择支付状态" clearable size="small">
                      <el-option label="请选择字典生成" value="" />
                    </el-select>
                  </el-form-item>
                                                                                                                  <el-form-item label="支付备注" prop="paymentDescription">
                    <el-input
                        v-model="queryParams.paymentDescription"
                        placeholder="请输入支付备注"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="币种" prop="currency">
                    <el-input
                        v-model="queryParams.currency"
                        placeholder="请输入币种"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="支付方式" prop="paymentMethod">
                    <el-input
                        v-model="queryParams.paymentMethod"
                        placeholder="请输入支付方式"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="产品类型" prop="productType">
                    <el-select v-model="queryParams.productType" placeholder="请选择产品类型" clearable size="small">
                      <el-option label="请选择字典生成" value="" />
                    </el-select>
                  </el-form-item>
                                                                                                                  <el-form-item label="产品编号" prop="productReference">
                    <el-input
                        v-model="queryParams.productReference"
                        placeholder="请输入产品编号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="卡详情" prop="cardDetails">
                    <el-input
                        v-model="queryParams.cardDetails"
                        placeholder="请输入卡详情"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账号名称" prop="accountDetailsAccountName">
                    <el-input
                        v-model="queryParams.accountDetailsAccountName"
                        placeholder="请输入账号名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账号编码" prop="accountDetailsAccountNumber">
                    <el-input
                        v-model="queryParams.accountDetailsAccountNumber"
                        placeholder="请输入账号编码"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账号银行编码" prop="accountDetailsBankCode">
                    <el-input
                        v-model="queryParams.accountDetailsBankCode"
                        placeholder="请输入账号银行编码"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账号支付金额" prop="accountDetailsAmountPaid">
                    <el-input
                        v-model="queryParams.accountDetailsAmountPaid"
                        placeholder="请输入账号支付金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="顾客邮箱" prop="customerEmail">
                    <el-input
                        v-model="queryParams.customerEmail"
                        placeholder="请输入顾客邮箱"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="顾客姓名" prop="customerName">
                    <el-input
                        v-model="queryParams.customerName"
                        placeholder="请输入顾客姓名"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="元数据名称" prop="metaDataName">
                    <el-input
                        v-model="queryParams.metaDataName"
                        placeholder="请输入元数据名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="元数据年龄" prop="metaDataAge">
                    <el-input
                        v-model="queryParams.metaDataAge"
                        placeholder="请输入元数据年龄"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="状态" prop="state">
                    <el-input
                        v-model="queryParams.state"
                        placeholder="请输入状态"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                                              <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['bizsys:ext_monnify_order:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['bizsys:ext_monnify_order:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['bizsys:ext_monnify_order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['bizsys:ext_monnify_order:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ext_monnify_orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
                                                          <el-table-column label="id" align="center" prop="id" />
                                                                      <el-table-column label="用户id" align="center" prop="usrId" />
                                                                      <el-table-column label="客户号" align="center" prop="custNo" />
                                                                      <el-table-column label="内部订单号" align="center" prop="paymentReference" />
                                                                      <el-table-column label="第三方订单号" align="center" prop="transactionReference" />
                                                                      <el-table-column label="已付金额" align="center" prop="amountPaid" />
                                                                      <el-table-column label="需付总金额" align="center" prop="totalPayable" />
                                                                      <el-table-column label="结算金额" align="center" prop="settlementAmount" />
                                                                      <el-table-column label="支付时间" align="center" prop="paidOn" />
                                                                      <el-table-column label="支付状态" align="center" prop="paymentStatus" />
                                                                      <el-table-column label="支付备注" align="center" prop="paymentDescription" />
                                                                      <el-table-column label="币种" align="center" prop="currency" />
                                                                      <el-table-column label="支付方式" align="center" prop="paymentMethod" />
                                                                      <el-table-column label="产品类型" align="center" prop="productType" />
                                                                      <el-table-column label="产品编号" align="center" prop="productReference" />
                                                                      <el-table-column label="卡详情" align="center" prop="cardDetails" />
                                                                      <el-table-column label="账号名称" align="center" prop="accountDetailsAccountName" />
                                                                      <el-table-column label="账号编码" align="center" prop="accountDetailsAccountNumber" />
                                                                      <el-table-column label="账号银行编码" align="center" prop="accountDetailsBankCode" />
                                                                      <el-table-column label="账号支付金额" align="center" prop="accountDetailsAmountPaid" />
                                                                      <el-table-column label="顾客邮箱" align="center" prop="customerEmail" />
                                                                      <el-table-column label="顾客姓名" align="center" prop="customerName" />
                                                                      <el-table-column label="元数据名称" align="center" prop="metaDataName" />
                                                                      <el-table-column label="元数据年龄" align="center" prop="metaDataAge" />
                                                                      <el-table-column label="状态" align="center" prop="state" />
                                                                      <el-table-column label="备注" align="center" prop="remark" />
                                                                                                                                                                                                          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['bizsys:ext_monnify_order:edit']"
          >修改</el-button>
          <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['bizsys:ext_monnify_order:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改monnify订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                                                                                                                                                            <el-form-item label="用户id" prop="usrId">
                          <el-input v-model="form.usrId" placeholder="请输入用户id" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="客户号" prop="custNo">
                          <el-input v-model="form.custNo" placeholder="请输入客户号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="内部订单号" prop="paymentReference">
                          <el-input v-model="form.paymentReference" placeholder="请输入内部订单号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="第三方订单号" prop="transactionReference">
                          <el-input v-model="form.transactionReference" placeholder="请输入第三方订单号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="已付金额" prop="amountPaid">
                          <el-input v-model="form.amountPaid" placeholder="请输入已付金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="需付总金额" prop="totalPayable">
                          <el-input v-model="form.totalPayable" placeholder="请输入需付总金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="结算金额" prop="settlementAmount">
                          <el-input v-model="form.settlementAmount" placeholder="请输入结算金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="支付时间" prop="paidOn">
                          <el-input v-model="form.paidOn" placeholder="请输入支付时间" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="支付状态">
                          <el-radio-group v-model="form.paymentStatus">
                            <el-radio label="1">请选择字典生成</el-radio>
                          </el-radio-group>
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="支付备注" prop="paymentDescription">
                          <el-input v-model="form.paymentDescription" placeholder="请输入支付备注" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="币种" prop="currency">
                          <el-input v-model="form.currency" placeholder="请输入币种" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="支付方式" prop="paymentMethod">
                          <el-input v-model="form.paymentMethod" placeholder="请输入支付方式" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="产品类型" prop="productType">
                          <el-select v-model="form.productType" placeholder="请选择产品类型">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="产品编号" prop="productReference">
                          <el-input v-model="form.productReference" placeholder="请输入产品编号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="卡详情" prop="cardDetails">
                          <el-input v-model="form.cardDetails" placeholder="请输入卡详情" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账号名称" prop="accountDetailsAccountName">
                          <el-input v-model="form.accountDetailsAccountName" placeholder="请输入账号名称" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账号编码" prop="accountDetailsAccountNumber">
                          <el-input v-model="form.accountDetailsAccountNumber" placeholder="请输入账号编码" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账号银行编码" prop="accountDetailsBankCode">
                          <el-input v-model="form.accountDetailsBankCode" placeholder="请输入账号银行编码" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账号支付金额" prop="accountDetailsAmountPaid">
                          <el-input v-model="form.accountDetailsAmountPaid" placeholder="请输入账号支付金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="顾客邮箱" prop="customerEmail">
                          <el-input v-model="form.customerEmail" placeholder="请输入顾客邮箱" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="顾客姓名" prop="customerName">
                          <el-input v-model="form.customerName" placeholder="请输入顾客姓名" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="元数据名称" prop="metaDataName">
                          <el-input v-model="form.metaDataName" placeholder="请输入元数据名称" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="元数据年龄" prop="metaDataAge">
                          <el-input v-model="form.metaDataAge" placeholder="请输入元数据年龄" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="状态" prop="state">
                          <el-input v-model="form.state" placeholder="请输入状态" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="备注" prop="remark">
                          <el-input v-model="form.remark" placeholder="请输入备注" />
                        </el-form-item>
                                                                                                                                                                                                                                                                                                                </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { listExt_monnify_order, getExt_monnify_order, delExt_monnify_order, addExt_monnify_order, updateExt_monnify_order, exportExt_monnify_order } from "@/api/bizsys/ext_monnify_order";

  export default {
    name: "Ext_monnify_order",
    components: {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
                  // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // monnify订单表格数据
              ext_monnify_orderList: [],
                  // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
                                                                                usrId: null,
                                                                    custNo: null,
                                                                    paymentReference: null,
                                                                    transactionReference: null,
                                                                    amountPaid: null,
                                                                    totalPayable: null,
                                                                    settlementAmount: null,
                                                                    paidOn: null,
                                                                    paymentStatus: null,
                                                                    paymentDescription: null,
                                                                    currency: null,
                                                                    paymentMethod: null,
                                                                    productType: null,
                                                                    productReference: null,
                                                                    cardDetails: null,
                                                                    accountDetailsAccountName: null,
                                                                    accountDetailsAccountNumber: null,
                                                                    accountDetailsBankCode: null,
                                                                    accountDetailsAmountPaid: null,
                                                                    customerEmail: null,
                                                                    customerName: null,
                                                                    metaDataName: null,
                                                                    metaDataAge: null,
                                                                    state: null,
                                                                                                                                                                                },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                createTime: [
                    { required: true, message: "创建时间不能为空", trigger: "blur" }
                  ],
                                                                                                                                        updateTime: [
                    { required: true, message: "更新时间不能为空", trigger: "blur" }
                  ]
                                    }
      };
    },
    created() {
      // this.getList();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    },
    methods: {
      /** 查询monnify订单列表 */
      getList() {
        this.loading = true;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            listExt_monnify_order(this.queryParams).then(response => {
          this.ext_monnify_orderList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
                                                    id: null,
                                                                    usrId: null,
                                                                    custNo: null,
                                                                    paymentReference: null,
                                                                    transactionReference: null,
                                                                    amountPaid: null,
                                                                    totalPayable: null,
                                                                    settlementAmount: null,
                                                                    paidOn: null,
                                                                paymentStatus: "0",
                                                                    paymentDescription: null,
                                                                    currency: null,
                                                                    paymentMethod: null,
                                                                    productType: null,
                                                                    productReference: null,
                                                                    cardDetails: null,
                                                                    accountDetailsAccountName: null,
                                                                    accountDetailsAccountNumber: null,
                                                                    accountDetailsBankCode: null,
                                                                    accountDetailsAmountPaid: null,
                                                                    customerEmail: null,
                                                                    customerName: null,
                                                                    metaDataName: null,
                                                                    metaDataAge: null,
                                                                    state: null,
                                                                    remark: null,
                                                                    createBy: null,
                                                                    createTime: null,
                                                                    updateBy: null,
                                                                    updateTime: null
                                    };
                  this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加monnify订单";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getExt_monnify_order(id).then(response => {
          this.form = response.data;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          this.open = true;
          this.title = "修改monnify订单";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (this.form.id != null) {
              updateExt_monnify_order(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addExt_monnify_order(this.form).then(response => {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm('是否确认删除monnify订单编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delExt_monnify_order(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
      },
              /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有monnify订单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportExt_monnify_order(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
      }
    }
  };
</script>
